<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 13-9-8
 * Time: 下午11:33
 * To change this template use File | Settings | File Templates.
 */

class Admin extends CI_Controller
{
    function index()
    {

        $this->load->library("form_validation");
        header("Content-type:text/html;charset=utf-8");
        $this->load->view("/admin/login");
    }

    function login()
    {
        
        $this->load->library("form_validation");
        $this->load->helper("url");
        $this->form_validation->set_rules("username", "UserName is Null", "required");
        $this->form_validation->set_rules("password", "Password is Null", "required");
        
        if($this->form_validation->run()===TRUE){
            $this->load->model("Admin_user");
            $data = $this->Admin_user->get_user();
            /**var_export($data);
             */
            if($data === 1){
                
                redirect("admin/frameset");
            }
            else
            {
                $this->form_validation->set_message("username or password error");
               /* redirect("/admin/index/");
                    */
                $this->load->view("/admin/login");
            }
        } 
        else
        {
            header("Content-type:text/html;charset=utf-8");
            $this->load->view("/admin/login");
        }
    }

    function header(){
        $this->load->helper("url");
        $this->load->view("headeradmin");
    }


    function left(){
        $this->load->helper("url");
        $this->load->view("/admin/adminmain");
    }

    function frameset(){
        $this->load->helper("url");
        header("Content-type:text/html;charset=utf-8");
        $this->load->helper('cookie');
        $this->input->set_cookie(array('step' => 'domainset'));
        $this->load->helper("url");
        $this->load->view("/admin/frameset"); 
    }

    function content(){
        $this->load->view("/admin/content");
    }
}
